<?php /*
	
*/ ?>
<?php include("system/config.inc.php");
$donotinclude = 1;
function generatePassword($length=9, $strength=0) {
	$vowels = 'aeuy';
	$consonants = 'bdghjmnpqrstvz';
	if ($strength & 1) {
		$consonants .= 'BDGHJLMNPQRSTVWXZ';
	}
	if ($strength & 2) {
		$vowels .= "AEUY";
	}
	if ($strength & 4) {
		$consonants .= '23456789';
	}
	if ($strength & 8) {
		$consonants .= '@#$%';
	}
 
	$password = '';
	$alt = time() % 2;
	for ($i = 0; $i < $length; $i++) {
		if ($alt == 1) {
			$password .= $consonants[(rand() % strlen($consonants))];
			$alt = 0;
		} else {
			$password .= $vowels[(rand() % strlen($vowels))];
			$alt = 1;
		}
	}
	return $password;
}
$Password = "";
$email = "";
if(isset($_REQUEST['submit']) && trim($_REQUEST['submit'])=="Send")
{
$varEmail = $_REQUEST['txt_username'];
	$sql = "SELECT * FROM  tbladmin  WHERE varemail = '$varEmail'";
	//echo $sql;
	$result = $obj_db->select($sql);
	if(count($result)>0)
	{
		//$Password = $result[0]['varcustpassword'];
		$Password = generatePassword();
		$mdpass=md5($Password);
		$email = $result[0]['varemail'];
		//$to=$email;
		//echo $to;
		//die();
		$headers="From:<".FROMEMAIL.">";
		$message="Your New Password is: ".$Password;
		$subject="Your new admin panel password";
		//mail($to, $mail_subject, $message, $headers);
		mail($email, $subject, $message, $headers);
		
		$sql1="update tbladmin set varpassword = '$mdpass' WHERE varemail ='$varEmail'";
	    $update_pass=mysql_query($sql1);
		
		header("location:index.php?msg=sent");
		die();
	  }
	}
?>
<?php include("inc/header.php");?>
<body>
<table width="80%" border="0" cellspacing="0" cellpadding="0" class="middlebackground" align="center">
  <tr>
    <td align="center"><table width="100%" border="0" cellspacing="0" cellpadding="0" >
  <tr>
    <td align="center"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td><?php include(INC."top.inc.php");?></td>
      </tr>
      <tr>
        <td ><table width="100%" border="0" cellspacing="0" cellpadding="0">
          
          
          <tr>
            <td height="300" align="left" class="style12" style="padding:15px;"><table width="343" border="0" align="center" cellpadding="5" cellspacing="5" class="border">
          <tr class="bg1">
			<td height="18" align="center">Forgotten Password</td>
			</tr>
		  <tr>
          <tr>
			<td style="padding-left:10px; padding-right:10px;"><form method="post" name="login" id="login" action="forgotpassword.php">
                <table  border="0" cellspacing="2" width="100%" cellpadding="2">
				<?php if($_REQUEST['invalid']=="val"){?>
                  <tr>
                    <td height="40" colspan="2" align="center">Invalid E-mail ID Please try again..! </td>
                    </tr>
					<?php }?>
					    <tr>
                    <td colspan="2">Please enter your email address if you are a valid user we will generate a new password and email it to you</td>
                    </tr>
                  <tr>
                    <td width="48">E-mail : </td>
                    <td width="204"><input name="txt_username" type="text" id="txt_username" size="30" /></td>
                  </tr>
              
                  <tr>
                    <td colspan="2" class="style15">&nbsp;</td>
                    </tr>
                  <tr>
                    <td colspan="2" align="center"><input name="submit" type="submit" class="btnbg" value="Send" border="0" /></td>
                    </tr>
                </table>
            </form></td>
          </tr>
        </table> </td>
          </tr>
        </table></td>
      </tr>
      
    </table></td>
  </tr>
</table></td>
  </tr>
</table>
<?php include "inc/footer.php";?>
